<?php
/**
 * La classe Database gestisce la connessione al DB tramite ADODB
 *
 * @author Stefano Poncini
 * @version 1.0
 */

require_once('adodb5/adodb.inc.php');


class Database{

	private $driver = 'mysql';
	private $host = 'localhost';
	private $user = 'root';
	private $password = '';
	//private $password = 'admin';
	private $database = 'blackjack';

	private static $instance = null;
	private $connection = null;

	private function __construct(){
		$DB = &ADONewConnection($this->getDriver());
		$DB->Connect($this->getHost(), $this->getUser(), $this->getPassword(), $this->getDatabase());
		$this->connection = $DB;
		$DB->setFetchMode(ADODB_FETCH_BOTH);
	}

	public static function getInstance(){
		if(!self::$instance){
			self::$instance = new Database();
		}

		return self::$instance;
	}

	public function getDriver() {
		return $this->driver;
	}

	public function setDriver($driver) {
		$this->driver = $driver;
	}

	public function getHost() {
		return $this->host;
	}

	public function setHost($host) {
		$this->host = $host;
	}

	public function getUser() {
		return $this->user;
	}

	public function setUser($user) {
		$this->user = $user;
	}

	public function getPassword() {
		return $this->password;
	}

	public function setPassword($password) {
		$this->password = $password;
	}

	public function getDatabase() {
		return $this->database;
	}

	public function setDatabase($database) {
		$this->database = $database;
	}

	public function getConnection() {
		return $this->connection;
	}

	public function setConnection($connection) {
		$this->connection = $connection;
	}
}
?>
